package PL.prac4;

import java.io.FileNotFoundException;
import java.io.IOException;

import org.antlr.runtime.ANTLRFileStream;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.Token;


/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args ) throws IOException, RecognitionException {
    	try {
    		ANTLRFileStream ent = new ANTLRFileStream(args[0]);
    		Analex analex = new Analex(ent);
    		Token token = analex.nextToken();
    		while(token.getType() != Token.EOF) {
    			System.out.println(token);
    			token = analex.nextToken();
    		}
    	}
    	/*catch (RecognitionException e) {
    		System.err.println(e.getMessage());
    	}*/
    	catch(FileNotFoundException fnfe) {
    		System.err.println("No se encontró el fichero");
    	} 
    	System.out.println("\n\n\n Fichero XML:");
    	try {
    		ANTLRFileStream ent = new ANTLRFileStream("entradaxml.xml");
    		Analexml analex = new Analexml(ent);
    		Token token = analex.nextToken();
    		while(token.getType() != Token.EOF) {
    			String x =token.toString();
    			System.out.println(x);
    			token = analex.nextToken();
    		}
    	}
    	/*catch (RecognitionException e) {
    		System.err.println(e.getMessage());
    	}*/
    	catch(FileNotFoundException fnfe) {
    		System.err.println("No se encontró el fichero");
    	}
    }
    
}
